import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
import VueAxios from 'vue-axios'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';
// import Cookies from 'js-cookie'
import VueRouter from 'vue-router';
Vue.use(VueRouter)
Vue.use(ElementUI);
Vue.use(Vuex);
Vue.use(VueAxios, axios);
Vue.config.productionTip = false;
//路由表
//import Hello from './components/HelloWorld'
import Test from './components/Test';
import Home from "./components/Home";
import Article from "./components/Article";
import Search from "./components/Search";
import Classify from "./components/Classify";
import Self from "./components/Self";
import Login from "./components/Login";
import NewUser from "./components/NewUser";
import Detail from "./components/Detail";
import admin from "./components/admin";
const routes = [
  { path: '/', component: Home },
  { path: '/test', component: Test },
  { path: '/article', component: Article },
  { path: '/search', component: Search },
  { path: '/classify', component: Classify },
  { path: '/self', component: Self },
  { path: '/login', component: Login },
  { path: '/newuser', component: NewUser },
  { path: '/Detail', component: Detail },
  { path: '/admin', component: admin },
]

//创建路由器实例，引入routes变量作为路由
const router = new VueRouter({
  routes,
  //mode: 'history'
})

// router.beforeEach((to,from,next)=>{
//   if(!Cookies.get('user_name')){//判断是否需要登录
//       next({
//         path:"/login",
//       })
//   }
// });

//定义vue实例
/*new Vue({
  render: h => h(App),
}).$mount('#app')*/

new Vue({
  render: h => h(App),
  //将上面声明的路由器传递到根Vue实例
  router
}).$mount('#app')//将这个实例挂载到id=app的根元素上
